// pages/search/search.js
import cache from '../../utils/Cache.js';
import url from '../../utils/url.js';
import http from '../../utils/http.js';
Page({

  /**
   * 页面的初始数据
   */
  data: {
	fangsList:[],
	top: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  //进行搜索操作
  dosearch:function(evt){
	  let that = this;
	  let kw = evt.detail.value.kw
	  if(!kw){
		  wx.showToast({
			  title:'请输入搜索词',
			  icon:'none'
		  })
		  that.setData({
		  	fangsList:[]
		  });
		  return false;
	  }
	  http.http(url.esfangs,'GET',{kw:kw},function(res){
		  console.log(res.data.length)
		  if(res.data.length > 0){
			  that.setData({
			  		fangsList:res.data
			  });
		  }else{
			  wx.showToast({
				  title:'暂无数据',
				  icon:'none'
			  })
			  that.setData({
			  	fangsList:[]
			  });
		  }
		  
	  });
  }
})